let sdk = window.sdk;
cc.Class({
    extends: cc.Component,

    properties: {
        ProgressBar: {
            default: null,
            type: cc.ProgressBar,
        },

        label: {
            default: null,
            type: cc.Label
        },
    },

    onLoad() {
        this.ProgressBar.progress = 0;
        cc.loader.onProgress = function(cur, num, itme) {
            var ps = this.ProgressBar.progress;
            this.s = (cur / num).toFixed(2);
            if (ps < this.s)
                ps += 0.02;
            this.ProgressBar.progress = ps;
        }.bind(this);

        //预加载
        cc.director.preloadScene('Main', function() {
            cc.loader.onProgress = null;
            if(sdk){
                let onMain = function(){
                    if(sdk.getLogin){
                        cc.director.loadScene('Main');
                        return;
                    } 
                    setTimeout(onMain,500);
                }
                if(sdk.getLogin){
                    cc.director.loadScene('Main');
                    return;
                } else {
                    setTimeout(onMain,500);
                }
            } else {
                cc.director.loadScene('Main');
            }
            //this.label.string = '资源加载完毕正在进入游戏...';
        });
    },

    start(){

    },
});